<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
    const myPlugin={
        //第一个参数是Vue的实例，第二个参数是要传递的数据
        install(app,options,param2){
            console.log(app,options,param2)
            //provide可以在祖先组件中指定我们想要提供给后代组件的数据或方法
            app.provide('name','hello provide')
            app.directive('focus',{
                mounted(el) {
                    el.focus();
                },
            }),
            app.mixin({
                mounted(){
                    console.log('plugin mixin')
                }
            })
        }
    }
    const app=Vue.createApp({
        template:`<div>hello</div>
        <input value="hello"/>
        <input v-focus />`,
        inject:['name'],
    })
    app.component('component-demo',{
        template:`<div>hello Vue.js</div>`
    })
    //插件的用法
    app.use(myPlugin,'a','b')
    app.mount("#app")
</script>
</html>